# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=dlfcn
pkgbase=mingw-w64-${_realname}-git
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-git"
pkgver=r66.e419539
pkgrel=1
pkgdesc="A wrapper for dlfcn to the Win32 API (mingw-w64)"
arch=('any')
url="https://github.com/dlfcn-win32/dlfcn-win32"
license=("LGPL")
provides=("${MINGW_PACKAGE_PREFIX}-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-svn")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "git")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=("${_realname}"::"git+https://github.com/dlfcn-win32/dlfcn-win32.git"
        unify-makefile.patch)
sha256sums=('SKIP'
            '92f3178a352496205ba77e91f2c6d758e834c845ae2cfce0ed59cf646fc65e57')

pkgver() {
  cd "${_realname}"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "${srcdir}/${_realname}"
  patch -p1 -i ${srcdir}/unify-makefile.patch
}

build() {
  cd "$srcdir/${_realname}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --libdir=${MINGW_PREFIX}/lib \
    --incdir=${MINGW_PREFIX}/include \
    --disable-stripping \
    --enable-shared \
    --disable-msvc

  make
}

package() {
  cd "${srcdir}/${_realname}"
  make DESTDIR="$pkgdir" install
}
